﻿using System;

abstract class Animal
{
    public abstract void voice();
}

class Cat : Animal
{
    public override void voice()
    {
        Console.WriteLine("miao");
    }
}
class Pig : Animal
{
    public override void voice()
    {
        Console.WriteLine("heng");
    }
}

class Dog : Animal
{
    public override void voice()
    {
        Console.WriteLine("woof");
    }
}

class Store
{
    public static Animal GetInstance (String animalType)
    {
        animalType = animalType.ToLower();

        if (animalType == "dog")
        {
            return new Dog();
        }
        else if (animalType == "pig")
        {
            return new Pig();
        }
        else
        {
            return new Cat();
        }
    }
}
class Program
{
    static void Main(string[] args)
    {
        Animal dog = Store.GetInstance("dog");
        Console.Write("狗的声音: ");
        dog.voice();

        Animal pig = Store.GetInstance("pig");
        Console.Write("猪的声音: ");
        pig.voice();

        Animal cat = Store.GetInstance("cat");
        Console.Write("猫的声音: ");
        cat.voice();
    }
}